import { Ast } from "../ast";
import { RedOpenContext, RedOpenVisitor } from "./RedOpen";

/**
 * 打开直播间红包弹框
 */
export class RedLiveRoomVisitor extends RedOpenVisitor {
    visitNode(node: Ast, ctx: RedOpenContext) {
        super.visitNode(node, ctx)
    }
    visitTextView(node: Ast, ctx: RedOpenContext) {
        // 打开直播间红包
        if (node.id.endsWith(`live_red_packet_status_text`) && node.visibleToUser) {
            if (node.parent.clickable) {
                ctx.open = () => node.parent.click()
                ctx.close = undefined;
            } else {
                ctx.open = () => node.parent.clickRect()
                ctx.close = undefined;
            }
            ctx.status = `opening`
        }
    }
}